package com.mark.springbootvideo.controller;

import com.mark.springbootvideo.entity.Video;
import com.mark.springbootvideo.service.VideoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * @Author: MARK
 * @Date: 2019/9/8 08:41
 * @Version: 1.0.0
 * @Description:
 */
@RestController
@Slf4j
@RequestMapping(value = "/api/v1/video", produces = {"application/json;charset=UTF-8"})
public class VideoController {

    @Resource
    private VideoService videoService;

    /**
     * @return java.util.List<com.mark.springbootvideo.entity.Video>
     * @create: 2019/9/8
     * @author MARK
     * @param page 当前第几页
     * @param size 每页几条
     * @Description: 分页接口
     */
    @GetMapping("/page")
    public List<Video> pageVideo(@RequestParam(value = "page", defaultValue = "1")Integer page,
                                 @RequestParam(value = "size", defaultValue = "10")Integer size){

        return videoService.findAll(page, size);
    }

    /**
     * @return com.mark.springbootvideo.entity.Video
     * @create: 2019/9/8
     * @author MARK
     * @param videoId 视频id
     * @Description: 根据id找视频
     */
    @GetMapping("/find_by_id/{videoId}")
    public Video findById(@PathVariable Integer videoId){
        return videoService.findById(videoId);
    }

}
